package com.ysd.lis.controller.lab;


import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.lab.LabRptGroup;
import com.ysd.lis.entity.lab.LabRptresult;
import com.ysd.lis.entity.lab.LabTemplate;
import com.ysd.lis.request.*;
import com.ysd.lis.service.lab.LabTemplateService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 检验模版 前端控制器
 * </p>
 *
 * @author HuiXing
 * @since 2024-01-02
 */
@RestController
@RequestMapping("/lab/template")
public class LabTemplateController extends BaseController {
    @Autowired
    LabTemplateService labTemplateService;

    //获取报告单元与工作组的树状结构数据
    @ApiOperation("获取报告单元树")
    @GetMapping("/getRptGroupTree")
    public Result getRptGroupTree( ) {
        return labTemplateService.getRptGroupTree();
    }

    //获取报告单元与工作组的树状结构数据
    @ApiOperation("获取图文报告报告单元树")
    @GetMapping("/getImgRptGroupTree")
    public Result getImgRptGroupTree( ) {
        return labTemplateService.getImgRptGroupTree();
    }


    @ApiOperation("新增模版")
    @PostMapping ("/addTemplate")
    public Result addTemplate(@RequestBody LabTemplate labTemplate) {
        return labTemplateService.addTemplate(labTemplate);
    }

    @ApiOperation("编辑报告单元")
    @PostMapping("/editTemplate")
    public Result editTemplate(@RequestBody LabTemplate labTemplate) {
        return labTemplateService.editTemplate(labTemplate);
    }

    @ApiOperation("获取当前报告单元的模版")
    @GetMapping ("/getTemplateByRptGroup")
    public Result getTemplateByRptGroup(@RequestParam(value = "rptGroup")String rptGroup,
                                        @RequestParam(value = "orgId",required = false) String orgId,
                                        @RequestParam(value = "searchValue",required = false) String searchValue
                                        ) {
        return labTemplateService.getTemplateByRptGroup(rptGroup,orgId,searchValue);
    }

    @ApiOperation("获取当前报告单元的模版及其细项")
    @GetMapping ("/getTemplateAndDetailByRptGroup")
    public Result getTemplateAndDetailByRptGroup(String rptGroup) {
        return  labTemplateService.getTemplateAndDetailByRptGroup(rptGroup);
    }


    @ApiOperation("分页查询")
    @GetMapping("/findTemplates")
    public Result findTemplates(Params params){
        return labTemplateService.findTemplates(params);
    }

    @ApiOperation("批量删除")
    @PostMapping("/batchDeleteTemplateList")
    public Result batchDeleteTemplateList(@RequestBody TemplateDto dto){
        return  labTemplateService.batchDeleteTemplateList(dto);
    }

    @ApiOperation("通过模版添加结果")
    @PostMapping("/batchInsertTemplateList")
    public Result batchInsertTemplateList(@RequestBody TemplateParams params){
        return  labTemplateService.batchInsertTemplateList(params);
    }

    @ApiOperation("通过模版添加结果")
    @PostMapping("/batchDefItemDictAndTemplate")
    public List<LabRptresult> batchDefItemDictAndTemplate(@RequestBody TemplateParams params){
        return  labTemplateService.batchDefItemDictAndTemplate(params);
    }
}
